<template>
  <el-dialog
    v-model:visible
    title="新增商品"
    width="60%"
  >
    <el-form :model="newProduct" ref="form">
      <el-form-item label="商品名称" required>
        <el-input v-model="newProduct.name" />
      </el-form-item>
      <el-form-item label="价格" required>
        <el-input type="number" v-model="newProduct.price" />
      </el-form-item>
      <el-form-item label="图片" required>
        <el-upload
          action="https://your-upload-url.com"
          :on-success="handleUploadSuccess"
        >
          <el-button type="primary">上传图片</el-button>
        </el-upload>
      </el-form-item>
      <el-form-item label="分类">
        <el-select v-model="newProduct.category">
          <el-option label="美妆" value="beauty" />
          <el-option label="鞋类" value="footwear" />
          <!-- 更多分类选项 -->
        </el-select>
      </el-form-item>
    </el-form>
    <template #footer>
      <el-button @click="closeModal">取消</el-button>
      <el-button type="primary" @click="saveProduct">保存</el-button>
    </template>
  </el-dialog>
</template>

<script setup lang="ts">
import { reactive } from 'vue';
import { ref } from 'vue';

const newProduct = reactive({
  name: '',
  price: 0,
  image: '',
  category: 'beauty'
});

const closeModal = () => {
  // 关闭弹窗逻辑
};

const handleUploadSuccess = (response) => {
  newProduct.image = response.data;
};

const saveProduct = () => {
  // 保存商品逻辑
};
</script>
